package com.translate.commons.config;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 这里是业务类
 * Spring定义的线程池会管理起来这里
 * 直接注入这个类，调用方法就能启动线程
 */
@Component
public class AsyncService {
    @Async("getTaskExector")
    public void doTaskThree(Long id) throws Exception {
        System.out.println("开始做任务"+id);
        long start = System.currentTimeMillis();
        Thread.sleep(10000);
        long end = System.currentTimeMillis();
        System.out.println("完成任务"+id+"，耗时：" + (end - start) + "毫秒");
    }
}

